package fr.syntheses.blog.Model.DAO.HQL;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;


import fr.syntheses.blog.beans.Style;


public class StyleDaoHib {
	
	
	Logger log = Logger.getLogger(StyleDaoHib.class);
	
	
	
	// Propeties 
	
	List<Style> listeStyles = new ArrayList<Style>();
	
	
	
	/**
	 * Cette methode permet de lister les styles.
	 * @return   List<style>
	 */
	public final List<Style> listerStyle() {
		
		
	
		
		Session session = null;
		
		Query query = null;
		
		try {
		
		session = HibernateUtil.getSession();
		
		try {
			query = session.createQuery("from Style order by Id ");
			Iterator style = query.iterate();
			
			while (style.hasNext()) {
				listeStyles.add((Style)style.next());
			}

		} finally {	}
		} catch (HibernateException e) {
			log.fatal("/* ATTENTION GRAVE ERREUR LORS DE LA CREATION DE LA SESSION FACTORY HB */");
			log.fatal(e);
		} finally {
			//HibernateUtil.closeSessionFactory();
		}
		return listeStyles;

	}

}
